<template>
  <div class="rights">
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>用户管理</el-breadcrumb-item>
      <el-breadcrumb-item>用户列表</el-breadcrumb-item>
    </el-breadcrumb>
    <el-table
      class="mt-15"
      :data="rightList"
      border
      style="width: 100%">
      <el-table-column
        type="index"
        width="50">
      </el-table-column>
      <el-table-column
        prop="authName"
        label="权限名称">
      </el-table-column>
      <el-table-column
        prop="path"
        label="路径">
      </el-table-column>
      <el-table-column
        label="层级">
        <template slot-scope="scope">
          <el-tag :type="getType(scope.row.level)">{{scope.row.level | fmtLevel}}</el-tag>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { getRightList } from '@/api'
export default {
  data () {
    return {
      rightList: []
    }
  },
  filters: {
    fmtLevel (level) {
      if (level === '0') {
        return '一级'
      } else if (level === '1') {
        return '二级'
      } else {
        return '三级'
      }
    }
  },
  created () {
    this.initTable()
  },
  methods: {
    initTable () {
      getRightList('list')
        .then(res => {
          this.rightList = res.data
        })
    },
    getType (level) {
      if (level === '0') {
        return 'success'
      } else if (level === '1') {
        return 'primary'
      } else {
        return 'warning'
      }
    }
  }
}
</script>

<style>
</style>
